FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["src/PhotoGalleryService.HttpApi.Host/PhotoGalleryService.HttpApi.Host.csproj", "src/PhotoGalleryService.HttpApi.Host/"]
COPY ["src/PhotoGalleryService.Application/PhotoGalleryService.Application.csproj", "src/PhotoGalleryService.Application/"]
COPY ["src/PhotoGalleryService.Application.Contracts/PhotoGalleryService.Application.Contracts.csproj", "src/PhotoGalleryService.Application.Contracts/"]
COPY ["src/PhotoGalleryService.Domain/PhotoGalleryService.Domain.csproj", "src/PhotoGalleryService.Domain/"]
COPY ["src/PhotoGalleryService.Domain.Shared/PhotoGalleryService.Domain.Shared.csproj", "src/PhotoGalleryService.Domain.Shared/"]
COPY ["src/PhotoGalleryService.EntityFrameworkCore/PhotoGalleryService.EntityFrameworkCore.csproj", "src/PhotoGalleryService.EntityFrameworkCore/"]
COPY ["src/PhotoGalleryService.HttpApi/PhotoGalleryService.HttpApi.csproj", "src/PhotoGalleryService.HttpApi/"]
RUN dotnet restore "src/PhotoGalleryService.HttpApi.Host/PhotoGalleryService.HttpApi.Host.csproj"
COPY . .
WORKDIR "/src/src/PhotoGalleryService.HttpApi.Host"
RUN dotnet build "PhotoGalleryService.HttpApi.Host.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "PhotoGalleryService.HttpApi.Host.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PhotoGalleryService.HttpApi.Host.dll"]